package com.neusoft.neuiotms.dcom.controller.problem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.bizcore.auth.common.bean.UserBean;
import com.neusoft.bizcore.web.dto.result.ResultDTO;
import com.neusoft.neuiotms.dcom.dto.problem.ProblemAssignmentDTO;
import com.neusoft.neuiotms.dcom.service.problem.ProblemAssignmentService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "问题指派")
@RestController
@RequestMapping(value = "/api/w/problem/assignment")
public class ProblemAssignmentController {

    @Autowired
    private ProblemAssignmentService problemAssignmentService;

    @ApiOperation("新增问题指派")
    @PostMapping
    public ResultDTO<ProblemAssignmentDTO> create(@RequestBody final ProblemAssignmentDTO dto, final UserBean user) {
        return ResultDTO.success(this.problemAssignmentService.create(dto, user));
    }

    @ApiOperation("查看问题指派")
    @GetMapping("/{workOrderNum}/{taskId}")
    public ResultDTO<ProblemAssignmentDTO> details(@PathVariable final String workOrderNum,
            @PathVariable final String taskId,
            final UserBean user) {
        return ResultDTO.success(this.problemAssignmentService.detail(workOrderNum, taskId, user));
    }
}
